package com.trainfinder.requestor;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Embeddable;

@Embeddable
public class JourneyPk implements Serializable {

	private static final long serialVersionUID = 1L;

	private int ticketType;

	private int ticketClass;

	private Date date;

	private char outwardOrReturn;


	public String toString() {
		return "outwardOrReturn=" + outwardOrReturn + ",ticketType="
				+ ticketType + ",ticketClass=" + ticketClass + ",date=" + date;
	}

	public boolean equals(Object o) {

		if (o == this) {
			return true;
		}

		if (o instanceof JourneyPk == false) {
			return false;
		}
		final JourneyPk j = (JourneyPk) o;

		return (j.getDate().toString().equals(this.getDate().toString())
				&& j.getOutwardOrReturn() == this.getOutwardOrReturn()
				&& j.getTicketClass() == this.getTicketClass() && j
				.getTicketType() == this.getTicketType());
	}

	public int hashCode() {
		return this.getDate().toString().hashCode();
	}
	
	public Date getDate() {
		return (Date)date.clone();
	}

	public void setDate(Date date) {
		this.date = (Date) date.clone();
	}

	public int getTicketClass() {
		return ticketClass;
	}

	public int getTicketType() {
		return ticketType;
	}

	public void setTicketType(int ticketType) {
		this.ticketType = ticketType;
	}

	public void setTicketClass(int ticketClass) {
		this.ticketClass = ticketClass;
	}

	public char getOutwardOrReturn() {
		return outwardOrReturn;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.trainfinder.datapersistace.IJourney#setOutwardOrReturn(char)
	 */
	public void setOutwardOrReturn(char outwardOrReturn) {
		this.outwardOrReturn = outwardOrReturn;
	}
	

}
